package com.westvalley.common.action.result;

import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import com.westvalley.common.kit.StringKit;

public class ActionResult {
	private String workFlowId;
	private String requestId;
	private String nodeId;
	private String operate;
	private String returnValue;
	private String errorMsg;
	private String operateDate;
	
	public static ActionResult me(RequestInfo requestInfo){
		return new ActionResult(requestInfo);
	}
	
	public static ActionResult me(RequestInfo requestInfo,Exception e){
		return new ActionResult(requestInfo,e);
	}
	
	public static ActionResult me(String workFlowId,String requestId,String nodeId,String operate,String returnValue,String errorMsg,String operateDate){
		return new ActionResult(workFlowId, requestId, nodeId, operate, returnValue, errorMsg, operateDate);
	}
	
	public ActionResult(){}
	
	public ActionResult(RequestInfo requestInfo){
		this(
			requestInfo.getWorkflowid(),
			requestInfo.getRequestid(),
			requestInfo.getRequestManager().getNodeid()+"",
			requestInfo.getRequestManager().getUserId()+"",
			Action.SUCCESS,
			"",
			StringKit.getCurrentDateTime()
		);
	}
	
	public ActionResult(RequestInfo requestInfo,Exception e){
		this(
			requestInfo.getWorkflowid(),
			requestInfo.getRequestid(),
			requestInfo.getRequestManager().getNodeid()+"",
			requestInfo.getRequestManager().getUserId()+"",
			Action.FAILURE_AND_CONTINUE,
			e.getMessage(),
			StringKit.getCurrentDateTime()
		);
	}
	
	public ActionResult(String workFlowId,String requestId,String nodeId,String operate,String returnValue,String errorMsg,String operateDate){
		this.workFlowId = workFlowId;
		this.requestId = requestId;
		this.nodeId = nodeId;
		this.operate = operate;
		this.returnValue = returnValue;
		this.errorMsg = errorMsg;
		this.operateDate = operateDate;
	}

	public String getWorkFlowId() {
		return workFlowId;
	}

	public void setWorkFlowId(String workFlowId) {
		this.workFlowId = workFlowId;
	}

	public String getRequestId() {
		return requestId;
	}

	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}

	public String getNodeId() {
		return nodeId;
	}

	public void setNodeId(String nodeId) {
		this.nodeId = nodeId;
	}

	public String getOperate() {
		return operate;
	}

	public void setOperate(String operate) {
		this.operate = operate;
	}

	public String getReturnValue() {
		return returnValue;
	}

	public void setReturnValue(String returnValue) {
		this.returnValue = returnValue;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public String getOperateDate() {
		return operateDate;
	}

	public void setOperateDate(String operateDate) {
		this.operateDate = operateDate;
	}
}
